package logic

import (
	"context"
	"mall/model/mysql"

	"mall/mallrpc/internal/svc"
	"mall/mallrpc/mallrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelLogic {
	return &DelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 购物车删除
func (l *DelLogic) Del(in *mallrpc.DelRequest) (*mallrpc.DelShResponse, error) {
	// todo: add your logic here and delete this line
	var shopcar mysql.Shopcar
	mysql.DB.Debug().Where("ID=?", shopcar.ID)
	//if shopcar.ID == 0 {
	//	return nil, fmt.Errorf("商品不存在无法删除")
	//}
	mysql.DB.Debug().Delete(&shopcar, shopcar.ID)
	return &mallrpc.DelShResponse{}, nil
}
